/*
 * Copyright 2013, NuzoweR@Schneefeuer <nuzower@gmail.com>.
 * The Settlers Online - Combat Simulator (tsosim).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef STATISTICS_H_
#define STATISTICS_H_

#include "Garrison.h"

class Statistics 
{
public:
	struct Data {
		Data() : unit(NULL), start_number(-1), number_iterations(0) {};

		const Unit* unit;
		int start_number;
		int number_iterations;
		std::list<int> iteration_results;
		struct Results {
			Results() : min(-1), max(-1), stat_min(-1), stat_max(-1), average(0), average_rounds(0) {}
			int min, max;
			int stat_min, stat_max;
			float average, average_rounds;
		} results;
	};

	typedef std::vector<Data> UnitData_t;
	UnitData_t unit_data;

	typedef std::map<const Unit*, int> UnitIndexMap_t;
	UnitIndexMap_t unit_index;

	Data rounds_data;

	void init(Garrison const& garrison);

	void ComputeAverage();
	void Print(std::ostream& out, bool show_minmax);
};


#endif // STATISTICS_H_
